* May 9, 2025
version 19.5

*************
* Prep Data *
*************

* We obtained qualtrics_survey.rds from https://doi.org/10.7910/DVN/9JWDKK
* and exported it as a CSV, which we load into Stata here
import delimited using "../data/qualtrics_survey.csv", varnames(1) asdouble clear
keep nukes_regime nukes_race nukes_strike ethno_nm_factor

* Independent variable: democracy treatment
gen byte t_democ = cond(nukes_regime == "dem", 1, 0)
label var t_democ "Country Regime"
label define t_democ 0 "Country is not a Democracy" 1 "Country is a Democracy"
label values t_democ t_democ
drop nukes_regime

* Independent variable: race treatment
gen byte t_race = 0 // race of target country. initialize as 0 = not mentioned
replace t_race = 1 if nukes_race == "white"
replace t_race = 2 if nukes_race == "nonwhite"
label var t_race "Country Race"
label define t_race 0 "Unspecified" 1 "Country Race is White" 2 "Country Race is Nonwhite"
label values t_race t_race
recode t_race 0=0 1/2=1, gen(t_racefixed) // was race fixed or not?
label var t_racefixed "Country Race Specified?"
label define t_racefixed 0 "No" 1 "Yes"
label values t_racefixed t_racefixed
drop nukes_race

* Dependent variable: support for strike
rename nukes_strike strike
tab strike, miss

* Moderator: ethnocentrism
rename ethno_nm_factor e3f
summarize e3f, detail
gen byte e3f_hi = cond(e3f > `r(p50)', 1, 0) if e3f ~= .

***********
* Analyze *
***********

capture log close
log using ../output/Test23.txt, text nomsg replace

* Table 3: Effect of Democracy and Race on Support for Military Strikes
regress strike i.t_democ ib2.t_race if t_race ~= 0, robust
etable, column(estimates) cstat(_r_b, nformat(%5.2f)) ///
   cstat(_r_se, nformat(%5.2f)) mstat(N) showstars showstarsnote ///
   export(../output/Table3.xlsx, replace)

* Table 4: Effect of Democracy, By Whether Race was Specified
regress strike t_democ##t_racefixed, robust
etable, column(estimates) cstat(_r_b, nformat(%5.2f)) ///
   cstat(_r_se, nformat(%5.2f)) mstat(N) showstars showstarsnote ///
   export(../output/Table4.xlsx, replace)

* Table 5: Effect of Democracy, By Whether Race Was Specified as White or Nonwhite *
regress strike t_democ##t_race if inlist(t_race,0,1), robust // column 1
estimates store m1
regress strike t_democ##t_race if inlist(t_race,0,2), robust // column 2
estimates store m2
etable, column(estimates) estimates(m1 m2) cstat(_r_b, nformat(%5.2f)) ///
   cstat(_r_se, nformat(%5.2f)) mstat(N) showstars showstarsnote ///
   export(../output/Table5.xlsx, replace)
	
log close